export const stacked = (that, containerId, entryData, midData, endData) => {
    // 获取echarts容器 生成echarts实例
    let myChart = that.$echarts.init(document.getElementById(containerId))
    let option = {
        title: {
            text: '成绩分析图'
        },
        tooltip: {
            trigger: 'axis',
            extraCssText: 'height:80px'
        },

        legend: {
            top: "10%",
            data: ['入学', '期中', '期末',]
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: ['语文', '数学', '英语', '理综', '文综',]
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                name: '入学',
                type: 'line',
                // stack: 'Total',
                data: entryData,
            },
            {
                name: '期中',
                type: 'line',
                // stack: 'Total',
                data: midData,
            },
            {
                name: '期末',
                type: 'line',
                // stack: 'Total',
                data: endData,
            }

        ]
    };
    // 将echarts与配置项联系到一起
    myChart.setOption(option);
    // 使屏幕的百分比宽度随着屏幕的变化而变化
    window.onresize = function () {
        myChart.resize();
    };
}


// 折线图

export const basisLine = (that, containerId, subject, gradeSubject) => {
    let myChart = that.$echarts.init(document.getElementById(containerId))
    let option = {
        title: {
            text: subject,
        },
        tooltip: {
            trigger: 'axis',
            extraCssText: 'height:80px'
        },

        xAxis: {
            type: 'category',
            data: ["入学", "期中", "期末"]
        },
        grid: {
            top: "20%",
            left: "5%",
            right: "5%",
            bottom: "5%",
            containLabel: true,
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data: gradeSubject,
                type: 'line'
            }
        ]
    };
    // 将echarts与配置项联系到一起
    myChart.setOption(option);
    // 使屏幕的百分比宽度随着屏幕的变化而变化
    window.onresize = function () {
        myChart.resize();
    };
}
